<template>
  <div class="main">
    <div class="headcard" style="height: 100vh">
      <div class="uc-header">
        <div class="back" @click="$router.back()">
          <img src="@/assets/img/3.png" />
        </div>
        <div class="title">{{ payWayTitle }} {{ $t("Payment") }}</div>
      </div>
      <div class="pay-way-box">
        <div class="pay-way">
          <div class="pay-item top">
            <div>{{ $t("Network") }}</div>
            <div>
              {{ chain_type }}
            </div>
          </div>
          <van-divider />
          <div class="pay-item bottom">
            <div>{{ $t("Amount") }}</div>
            <div>
              {{ amount }}
            </div>
          </div>
        </div>
      </div>
      <div class="qr-box">
        <div class="qr-title">{{ $t("paymentTips1") }}</div>
        <div class="qr-img">
          <div ref="cbcCode"></div>
        </div>
        <div class="qr-title">{{ $t("PaymentAddress") }}</div>
        <div class="pay-way-box">
          <div class="pay-way address-box">
            <div class="pay-item top">
              <div class="address">
                {{ address }}
              </div>
            </div>
          </div>
        </div>
        <div class="btn" @click="copy">{{ $t("CopyAddress") }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import QRCode from "qrcodejs2";
import { copyText } from "@/utils/common";

export default {
  name: "orderPay",
  data() {
    return {
      payWayTitle: "",
      chain_type: "",
      amount: "",
      address: "",
    };
  },
  created() {
    this.init();
  },
  methods: {
    copy() {
      copyText(this.address);
      this.$toast(this.$t("copySuccess"));
    },
    init() {
      const { pay_channel, chain_type, amount, address } = JSON.parse(
        this.$route.query.item
      );
      this.chain_type = chain_type;
      this.amount = amount;
      this.address = address;
      pay_channel.includes("USDT")
        ? (this.payWayTitle = this.$t("USDT"))
        : (this.payWayTitle = this.$t("FastPay"));
      this.$nextTick(() => {
        new QRCode(this.$refs.cbcCode, {
          text: address,
          width: 200,
          height: 200,
          colorDark: "#000000",
          colorLight: "#ffffff",
          correctLevel: QRCode.CorrectLevel.H,
        });
      });
    },
  },
};
</script>

<style lang="less" scoped>
@import url("./acc.less");

* {
  // font-weight: 800;
  color: #93653e;
}
.qr-box {
  .qr-title {
    font-size: 30px;
    height: 60px;
    // color: #9a9a9c;
    color: white;
    flex-shrink: 0;
    font-weight: 700;
    margin: 30px;
  }
  .qr-img {
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
}
.address-box {
  padding: 25px !important;
}
.pay-way-box {
  margin: 30px;
  .pay-way {
    // background: #ced4f8;
    background-color: #f9f3dd;
    // display: flex;
    justify-content: space-between;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    .top {
      margin-bottom: 20px;
    }
    .bottom {
      margin-top: 20px;
    }
    .pay-item {
      display: flex;
      justify-content: space-between;
      height: 100%;
      .address {
        font-size: 24px;
      }
    }
  }
}
.btn {
  margin: 0 auto;
  margin-top: 50px;
  width: 682px;
  height: 76px;
  background: #f9f3dd;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0px;
  // color: rgba(255, 255, 255, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  // transition: all 0.05s;
  user-select: none;
}
</style>
